/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.camachosanchez.controler.jdbc;

import com.camachosanchez.bean.TiposVehiculo;
import com.camachosanchez.util.ConexionSQL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Zully
 */
public class TipoVehiculoJdbcControler {
    
    public List<TiposVehiculo> findAll() {
        List<TiposVehiculo> lst = new ArrayList<TiposVehiculo>();
        Connection cn = ConexionSQL.obtenerConexion();
        Statement st;
        try {
            st = cn.createStatement();
            ResultSet rs = st.executeQuery("SELECT id, nombre FROM tipos_vehiculo t;");
            while (rs.next()) {
                TiposVehiculo tipoV = new TiposVehiculo();
                tipoV.setId(rs.getShort(1));
                tipoV.setNombre(rs.getString(2));
                TipoEjeJdbcControler dao_jdbc = new TipoEjeJdbcControler();
                tipoV.setTiposEjeList(dao_jdbc.findTipoEjeFromTipoVehiculo(tipoV.getId()));
                lst.add(tipoV);
            }
            rs.close();
            st.close();
            cn.close();
        } catch (SQLException ex) {
            Logger.getLogger(TalleresJdbcControler.class.getName()).log(Level.SEVERE, null, ex);
        }
        return lst;
    }
    
}
